/**
 * @description 项目中使用到的数据弹窗，表单控件有非常多需求使用高级弹窗的，皆引用下面的对象，解构并覆盖属性即可
 * @link https://cf.annto.com/pages/viewpage.action?pageId=34343248
 */

/**
 * @description 车型弹窗搜索
 */
export const advanceCarType = {
    label: '车型',
    prop: 'equipmentType',
    value: 'equipmentType',
    type: 'advance',
    advanceConfig: [
        { prop: 'cdegCode', value: '车型编码' },
        { prop: 'cdegNameCn', value: '车型名称' },
    ],
    tableConfig: [
        { prop: 'cdegCode', value: '车型编码' },
        { prop: 'cdegNameCn', value: '车型名称' },
    ],
    advanceUrl: '/cdTsEquipmentGroup/pageSearch',
    // TODO 更换车型服务地址
    prefix: '//icloudopapi-sit.annto.com/api-saas-op/dc',
    cbParams: ['cdegCode#equipmentType', 'cdegNameCn#equipmentName'],
};

/**
 * @description 仓库弹窗搜索
 */
export const advancewarehouseType = {
    name: '仓库',
    advanceLabel: '选择仓库',
    value: 'whName',
    advanceConfig: [
        { prop: 'cdwhName', value: '仓库名称' },
        { prop: 'whCode', value: '仓库编码' },
    ],
    tableConfig: [
        { prop: 'whCode', value: '仓库编码' },
        { prop: 'cdwhName', value: '仓库名称' },
        { prop: 'detailAddress', value: '仓库地址' },
        {
            prop: 'cdwhType',
            value: '仓库类型',
            type: 'select',
            options: {
                1: '平库',
                2: '立体库',
                3: '楼库',
                4: '恒温库',
                5: '高台库',
                6: '双层坡道库',
                7: '三层坡道库',
                8: '四层坡道库',
                9: '四层以上坡道库',
            },
        },
        {
            prop: 'cdwhProperty',
            value: '产权属性',
            type: 'select',
            options: {
                1: '安得自建',
                2: '安得租赁',
                3: '客户自建',
                4: '美的自建',
                5: '客户租赁',
                6: '协议建仓',
            },
        },
    ],
    advanceUrl: '/cdWarehouse/page',
    prefix: `/api-saas-dc/app`,
    type: 'advance',
    cbParams: ['whCode', 'cdwhName#whName'],
};
/**
 * @description 发货人管理-分页查询
 */
export const advanceSenderType = {
    label: '发货方名称',
    prop: 'senderName',
    type: 'advance',
    width: 100,
    advanceConfig: [
        {
            prop: 'shipperNameCn',
            value: '发货方名称',
        },
        {
            prop: 'shipperCode',
            value: '发货方编码',
        },
    ],
    tableConfig: [
        {
            prop: 'shipperCode',
            value: '发货方编码',
        },
        {
            prop: 'shipperNameCn',
            value: '发货方名称',
        },
        {
            prop: 'contact',
            value: '联系人',
        },
        {
            prop: 'provinceName',
            value: '省',
        },
        {
            prop: 'cityName',
            value: '市',
        },
        {
            prop: 'districtsName',
            value: '区',
        },
        {
            prop: 'townName',
            value: '县',
        },
        {
            prop: 'address',
            value: '详细地址',
        },
    ],
    method: 'post',
    prefix: '/api-saas-dc/app/',
    advanceUrl: 'ebShipper/page?status=1',
    cbParams: [
        'shipperNameCn#senderName',
        'shipperCode#senderCode',
        'contact#senderContact',
        'contactTel#senderTel',
        'phone#senderMobile',
        'address#senderDetailAddr',
        'eblcCode#eblcCode',
        // 地址组件
        'districts#senderDistrictCode',
        'districtsName#senderDistrictName',
        'city#senderCityCode',
        'cityName#senderCityName',
        'town#senderTownCode',
        'townName#senderTownName',
        'province#senderProvinceCode',
        'provinceName#senderProvinceName',
    ],
    advanceCallback(data) {
        data.senderAddrCode = [
            data.senderProvinceCode,
            data.senderCityCode,
            data.senderDistrictCode,
            data.senderTownCode,
        ];

        data.senderAddrName = [
            data.senderProvinceName,
            data.senderCityName,
            data.senderDistrictName,
            data.senderTownName,
        ];
        return data;
    },
};
/**
 * @description 收货人管理-分页查询
 */
export const advanceReceiverType = {
    label: '收货方名称',
    prop: 'receiverName',
    mustFill: true,
    type: 'advance',
    width: 100,
    advanceConfig: [
        {
            prop: 'shipperNameCn',
            value: '收货方名称',
        },
        {
            prop: 'shipperCode',
            value: '收货方编码',
        },
    ],
    tableConfig: [
        {
            prop: 'shipperCode',
            value: '收货方编码',
        },
        {
            prop: 'shipperNameCn',
            value: '收货方名称',
        },
        {
            prop: 'provinceName',
            value: '省',
        },
        {
            prop: 'cityName',
            value: '市',
        },
        {
            prop: 'districtsName',
            value: '区',
        },
        {
            prop: 'townName',
            value: '县',
        },
        {
            prop: 'contact',
            value: '联系人',
        },
        {
            prop: 'address',
            value: '详细地址',
        },
        // {
    ],
    method: 'post',
    prefix: '/api-saas-dc/app/',
    advanceUrl: 'ebShipper/page?status=1',
    cbParams: [
        'shipperNameCn#receiverName',
        'shipperCode#receiverCode',
        'contact#receiverContact',
        'phone#receiverMobile',
        // 'contactTel#receiverTel',
        'address#receiverDetailAddr',
        // 地址转换
        'districts#receiverDistrictCode',
        'districtsName#receiverDistrictName',
        'city#receiverCityCode',
        'cityName#receiverCityName',
        'town#receiverTownCode',
        'townName#receiverTownName',
        'province#receiverProvinceCode',
        'provinceName#receiverProvinceName',
    ],
    // 初始化的时候需要
    advanceCallback(data) {
        data.receiverAddrCode = [
            data.receiverProvinceCode,
            data.receiverCityCode,
            data.receiverDistrictCode,
            data.receiverTownCode,
        ];
        data.receiverAddrName = [
            data.receiverProvinceName,
            data.receiverCityName,
            data.receiverDistrictName,
            data.receiverTownName,
        ];
        return data;
    },
};

export const advanceCustomerType = {
    name: '请输入客户名称',
    advanceLabel: '客户',
    value: 'customerName',
    advanceConfig: [
        { prop: 'ebcuNameCn', value: '客户名称' },
        { prop: 'pmCode', value: '客户编码' },
    ],
    tableConfig: [
        { prop: 'pmCode', value: '客户编码' },
        { prop: 'ebcuNameCn', value: '客户名称' },
    ],
    advanceUrl: '/ebCustomer/searchByEbCustomer',
    cbParams: ['pmCode#customerCode', 'ebcuNameCn#customerName'],
};
export const advanceGoodsItemType = {
    label: '商品中文名称',
    prop: 'itemName',
    type: 'advance',
    width: 160,
    advanceConfig: [
        {
            prop: 'cdcmNameCn',
            value: '商品中文名称',
        },
        {
            prop: 'cdcmMaterialNo',
            value: '商品编码',
        },
        {
            prop: 'cdcmCustomerCode',
            value: '客户商品编码',
        },
    ],
    tableConfig: [
        {
            prop: 'cdcmMaterialNo',
            value: '商品编码',
            width: 100,
        },
        {
            prop: 'cdcmCustomerCode',
            value: '客户商品编码',
            width: 130,
        },
        {
            prop: 'cdcmNameCn',
            value: '商品中文名称',
        },
        {
            prop: 'cdcmCube',
            value: '体积',
            width: 60,
        },
        {
            prop: 'cdcmWeight',
            value: '毛重',
            width: 60,
        },
    ],
    method: 'post',
    prefix: '/api-saas-dc/app',
    advanceUrl: '/cdCommonMaterial/pageSearch',
    cbParams: [
        'cdcmMaterialNo#itemCode',
        'cdcmCustomerCode#customerItemCode',
        'cdcmNameCn#itemName',
        'sizeIdentification#itemSize',
        'specificationUnit#specificationUnit',
        'cdcmWeight#grossWeight',
        'cdcmNetWeight#net_weight',
        'cdcmCube#volume',
    ],
};

/** 组织架构 */
export const advanceOrgsType = {
    label: '组织架构',
    prop: 'siteName',
    value: 'siteName',
    mustFill: true,
    type: 'advance',
    width: 240,
    advanceConfig: [
        {
            prop: 'name',
            value: '组织名称',
        },
        {
            prop: 'code',
            value: '组织系统代码',
        },
    ],
    tableConfig: [
        {
            prop: 'code',
            value: '组织系统代码',
        },
        {
            prop: 'name',
            value: '组织名称',
        },
    ],
    method: 'post',
    prefix: '/api-saas-auth/core',

    advanceUrl: '/public/organizations',
    cbParams: ['code#siteCode', 'name#siteName'],
    beforeRequest(params) {
        params.tenantCode = store.getters.currentTenant?.tenantCode;
        return params;
    },
};

/**
 * @description 供应商
 */
export const advanceCarrierType = {
    label: '供应商',
    prop: 'carrierName',
    name: '供应商',
    value: 'carrierName',
    type: 'advance',
    mustFill: true,
    isFixed: true,
    span: 3,
    width: 240,
    advanceConfig: [
        { prop: 'supplierNameCn', value: '供应商名称' },
        { prop: 'supplierCode', value: '供应商编码' },
    ],
    tableConfig: [
        { prop: 'supplierNameCn', value: '供应商名称' },
        { prop: 'supplierCode', value: '供应商编码' },
    ],
    advanceUrl: '/supplier/info/selectPage',
    prefix: '/api-saas-srm/app',
    cbParams: ['supplierCode#carrierCode', 'supplierNameCn#carrierName'],
    advanceCode: 'advanceCode',
};
